import {
    payrollList
} from '../../api/pay'
Page({
    data: {
        data: [],
        pageNum:1,
        pageSize:10,
        hasNextPage:false
    },
    onLoad: function () {
        this.getPayrollList()
    },
    getPayrollList(){
        payrollList({
            pageNum:this.data.pageNum,
            pageSize:this.data.pageSize
        }).then(res => {
            if(res.hasNextPage){
                this.data.hasNextPage = res.hasNextPage
            }else{
                this.data.hasNextPage = res.hasNextPage
            }
            let arr = []
            arr.push(...this.data.data)
            arr.push(...res.list)
            this.setData({
                data: arr
            })
        })
    },
    goQrcode() {
        wx.navigateTo({
            url: '/packagePay/pages/payroll-poster/payroll-poster',
        })
    },
    goDetail(event) {
        wx.navigateTo({
            url: '/packagePay/pages/payroll-workers/payroll-workers?id=' + event.currentTarget.dataset.id,
        })
    },
    threshold(){
        if(!this.data.hasNextPage){
            return
        }
        this.setData({
            pageNum:this.data.pageNum += 1
        })
        this.getPayrollList()
    }
})